<template>
  <div>
    <setHeader title="" class="sethead_white"></setHeader>
    <div class="pagecontent" style="background-color: #fff;">
      <h3 class="mt-notices">{{returnInfoTitle}}</h3>
      <small class="inCompany_insert">
        <img class="company_img" src="../common/images/youquan.png" alt="">
      </small>
      <p class="company_bind_name">{{companyName}}</p>

      <!-- <mt-field label="管理员姓名：" placeholder="请输入用户名" v-model="returnInfoUser" disabled="disabled"></mt-field>
      <mt-field label="管理员电话：" placeholder="请输入用户名" v-model="returnInfoTel" disabled="disabled"></mt-field>
      <mt-field label="你的姓名：" placeholder="用户名" v-model="userInfo.username" disabled="disabled"></mt-field>
      <mt-field label="你的职位：" placeholder="请输入你的职位" v-model="userJob"></mt-field>
      <mt-field label="申请信息：" placeholder="请输入申请内容" v-model="applyInfo" style="border-bottom: none;"></mt-field> -->

      <!-- <mt-button type="primary" size="normal" class="el-long-button el-long-create-button"  @click.native="applyCompany">申请加入</mt-button> -->
      <div class="btn_big_red primary_add" @click="applyCompany">
          <button>申请加入</button>
      </div>
    </div>
  </div>

</template>

<script>
import setHeader from '../public/setHeader.vue';
  import { MessageBox } from 'mint-ui';
  export default {
 
    data() {
      return {
      	headerTitle:'',
        companyName: '',
        returnInfoTitle: '该企业已存在，且已有管理员',
        returnInfoUser: '',
        returnInfoTel: '',
        userInfo:'',
        uid: '',
        cp_id:''
      };
    },
    components:{
    	setHeader,
    },
    created() {
      let that = this;
      that.userInfo = window.localStorage.getItem('userInfo');
      that.userInfo = JSON.parse(that.userInfo);
      that.uid = that.userInfo.uid;
    },
    mounted() {
      // let that = this;
      // var user = Promise.resolve(this.getUserInfo())
      // user.then(
      //   function (result) { 
      //   // console.log(9999);
      //   that.userInfo = result;
      //   that.uid = result.uid;
      // })

      this.companyName = this.$route.query.companyName;
      this.returnInfoUser = this.$route.query.adminName;
      this.returnInfoTel = this.$route.query.tel;
      this.cp_id = this.$route.query.cp_id;
      // console.log(this.$route.query.companyName);
    },

    methods: {

      applyCompany(){
        let that = this;
        var companyName = that.companyName;
        var userName = that.userInfo.username;
        // var cp_id = this.userJob
        // var applyInfo = this.applyInfo
        var userId = that.uid;
        var cp_id = that.cp_id;
        var access_token = window.localStorage.getItem('access_token');
        that.$router.push({path:'/inCompanyTwo', query: {companyName, userId, userName, access_token,cp_id}});
        
        // if(companyName){
        //   this.$fetch(this.$path + '/api.php/company/userApplyInCompany', {companyName, userId, userName, access_token}).then((response) => {
        //     console.log('进来了',response);
        //     if(response.code != 200){
        //       MessageBox('提示', response.msg)
        //       return false;
        //     }else{
              
        //       // that.$openDialog({
        //       //   src: require('../common/images/smile.jpg'),
        //       //   title: '加入申请成功',
        //       //   message: '请等待管理员审核',
        //       //   messagemore: '管理员：131-1230-8868',
        //       //   okText: '完成',
        //       //   callback (flag) {
        //       //     if(flag) {
        //       //       // that.$router.push({path:'/userCenter'});
                    
        //       //     }  
        //       //   }
        //       // });

        //       // MessageBox.alert(response.msg).then(action => {
        //       //   this.$router.push({path: '/inCompanyOk', query: {cp_id:response.data.cp_id,adminName:this.returnInfoUser, tel:this.returnInfoTel}}); 
        //       // });
        //     } 
        //   })
        // }
      },
    }
  }

</script>
<style >
.sethead_white .header_array_text_white{
  background-color: #FFF !important;
  color: #333 !important;
}

/* 创建企业标题 */
.mt-notices{
    font-size: 0.28rem;
    color: #999;
    font-weight: 400;
    text-align: center;
    padding: 0.6rem 0 0.4rem 0;
    line-height: 0.56rem;
}
.inCompany_insert {
  width: 1.1rem;
  height: 1.1rem;
  text-align: center;
  vertical-align: middle;
}
.inCompany_insert .company_img {
  width: 1.1rem;
  height: 1.1rem;
  max-width: 100%;
  max-height: 100%;
  border-radius: 50%;
}
.company_bind_name {
  font-size: 0.34rem;
  color: #333;
}

/* input样式 */
.mint-cell-text {
  font-size: 0.28rem;
  color: #333;
}

/* 申请加入 */
.primary_add {
  margin-top: 0.4rem;
}
</style>
